package raytracing.gui;

import java.awt.Graphics;
import java.awt.image.BufferedImage;

import javax.swing.JFrame;
import javax.swing.JPanel;

import raytracing.RayTracer;

public class ShowJFrame extends JPanel {
/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	BufferedImage img;
	
	//	public void paint(Graphics g) {
//	    g.drawImage( image, 0, 0, null);
//	  }
//
//	  static public void main(String args[]) throws
//	Exception {
//	    JFrame frame = new JFrame("Display image");
//	    Panel panel = new ShowImage();
//	    frame.getContentPane().add(panel);
//	    frame.setSize(500, 500);
//	    frame.setVisible(true);
//	  }
	public ShowJFrame() {
		super();
	}
	
	public ShowJFrame(RayTracer rayTracer) {
		super();
		JFrame frame = new JFrame("Enjoy ...");
		img = rayTracer.getBuf();
	    this.paint(img.createGraphics());
	    frame.getContentPane().add(this);
//	    frame.setSize(rayTracer.width+10, rayTracer.height+10);
	    frame.setBounds(100, 100, rayTracer.width, rayTracer.height);
	    frame.setVisible(true);
	}
	
	@Override
	public void paint(Graphics g) {
		//draw the image
		if( img != null)
			g.drawImage(img,0,0, this);
	}


}
